﻿/*-----------------------------------------------------------------------
 * <copyright file="WCFStaffCorrelation.svc.cs" company="O-RID">
 *     Copyright (c)2010 O-RID Co.,Ltd.
 * </copyright>
 * <author>Zhang Jun</author>
 * <summary>
 *          所有与 全员 信息操作相关的所有服务
 *          StatisticsToolsDB_new 数据库
 *
 *          作成日： 07/12/2010
 *                   07/13/2010  增加 全员别 日别/小时别 稼动率 
 *                   06/09/2011  增加 全员别日别查询、全员别期间别查询 追加案件名，线路选项
 * </summary>
 *-----------------------------------------------------------------------
 */


namespace Orid.Management.Statistics.Service.OPUnitService.StaffCorrelation
{
    using System;
    using System.Collections.Generic;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using Orid.Management.Statistics.Service.OPUnitService.StaffCorrelation.ServiceModel;

    /// <summary>
    /// 注意: 如果更改此处的类名 "WCFStaffCorrelation"，也必须更新 Web.config 中对 "WCFStaffCorrelation" 的引用。
    /// </summary>
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class WCFStaffCorrelation : IWCFStaffCorrelation
    {

        #region 全员别 日别 生产性
        /// <summary>
        /// 全员别日别生产性
        /// </summary>
        /// <param name="whereParametersList">参数列表</param>
        /// <returns>生产性信息</returns>
        public List<StaffEntrySpeedQueryInforData> SelectStaffEntrySpeedQueryInfor(List<WhereParameters> whereParametersList) 
        {
            List<StaffEntrySpeedQueryInforData> staffEntrySpeedQueryInforDataList = null;
            try
            {

                #region 参数形式转换

                ////日期
                if (!whereParametersList[0].WhereentryDateFrom.Equals("null"))
                {
                    whereParametersList[0].WhereentryDateFrom = whereParametersList[0].WhereentryDateFrom.ToString().Trim();
                }

                if (!whereParametersList[0].WhereentryDateTo.Equals("null"))
                {
                    whereParametersList[0].WhereentryDateTo = whereParametersList[0].WhereentryDateTo.ToString().Trim();
                }

                ////jobclass
                if (String.IsNullOrEmpty(whereParametersList[0].WhereJobClass))
                {
                    whereParametersList[0].WhereJobClass = string.Empty;
                }
                else
                {
                    whereParametersList[0].WhereJobClass = whereParametersList[0].WhereJobClass.ToString().Trim();
                }

                ////ScriptType
                if (String.IsNullOrEmpty(whereParametersList[0].WhereScriptType))
                {
                    whereParametersList[0].WhereScriptType = string.Empty;
                }
                else
                {
                    whereParametersList[0].WhereScriptType = whereParametersList[0].WhereScriptType.ToString().Trim();
                }

                ////WordType
                if (String.IsNullOrEmpty(whereParametersList[0].WhereWordType))
                {
                    whereParametersList[0].WhereWordType = string.Empty;
                }
                else
                {
                    whereParametersList[0].WhereWordType = whereParametersList[0].WhereWordType.ToString().Trim();
                }

                ////案件名 
                if (!string.IsNullOrEmpty(whereParametersList[0].WhereMatterName))
                {
                    whereParametersList[0].WhereMatterName = whereParametersList[0].WhereMatterName.Trim();
                }
                else
                {
                    whereParametersList[0].WhereMatterName = DBNull.Value.ToString();
                }

                ////线路
                if (!string.IsNullOrEmpty(whereParametersList[0].WhereServer))
                {
                    whereParametersList[0].WhereServer = whereParametersList[0].WhereServer.Trim();
                }
                else
                {
                    whereParametersList[0].WhereServer = DBNull.Value.ToString();
                }

                #endregion

                staffEntrySpeedQueryInforDataList = DataProvider.GetSelectStaffEntrySpeedQueryInfor(whereParametersList);
            }
            catch (Exception ex)
            {
                Log4Service.Log log = new Orid.Management.Statistics.Service.Log4Service.Log();
                log.Error("WCFStaffCorrelation SelectStaffEntrySpeedQueryInfor Error:" + ex.Message);
            }

            return staffEntrySpeedQueryInforDataList;

        }
        #endregion 全员别 日别 生产性

        #region 全员别 期间别 生产性
        /// <summary>
        /// 全员别 期间别 生产性
        /// </summary>
        /// <param name="whereParametersList">参数列表</param>
        /// <returns>生产性信息</returns>
        public List<StaffDurationEntrySpeedQueryInforData> SelectStaffDurationEntrySpeedQueryInfor(List<WhereParameters> whereParametersList) 
        {
            List<StaffDurationEntrySpeedQueryInforData> staffDurationEntrySpeedQueryInforDataList = null;
            try
            {
                #region 参数形式转换

                ////日期
                if (!whereParametersList[0].WhereentryDateFrom.Equals("null"))
                {
                    whereParametersList[0].WhereentryDateFrom = whereParametersList[0].WhereentryDateFrom.ToString().Trim();
                }

                if (!whereParametersList[0].WhereentryDateTo.Equals("null"))
                {
                    whereParametersList[0].WhereentryDateTo = whereParametersList[0].WhereentryDateTo.ToString().Trim();
                }

                ////jobclass
                if (String.IsNullOrEmpty(whereParametersList[0].WhereJobClass))
                {
                    whereParametersList[0].WhereJobClass = string.Empty;
                }
                else
                {
                    whereParametersList[0].WhereJobClass = whereParametersList[0].WhereJobClass.ToString().Trim();
                }

                ////ScriptType
                if (String.IsNullOrEmpty(whereParametersList[0].WhereScriptType))
                {
                    whereParametersList[0].WhereScriptType = string.Empty;
                }
                else
                {
                    whereParametersList[0].WhereScriptType = whereParametersList[0].WhereScriptType.ToString().Trim();
                }

                ////WordType
                if (String.IsNullOrEmpty(whereParametersList[0].WhereWordType))
                {
                    whereParametersList[0].WhereWordType = string.Empty;
                }
                else
                {
                    whereParametersList[0].WhereWordType = whereParametersList[0].WhereWordType.ToString().Trim();
                }

                ////案件名 
                if (!string.IsNullOrEmpty(whereParametersList[0].WhereMatterName))
                {
                    whereParametersList[0].WhereMatterName = whereParametersList[0].WhereMatterName.Trim();
                }
                else
                {
                    whereParametersList[0].WhereMatterName = DBNull.Value.ToString();
                }

                ////线路
                if (!string.IsNullOrEmpty(whereParametersList[0].WhereServer))
                {
                    whereParametersList[0].WhereServer = whereParametersList[0].WhereServer.Trim();
                }
                else
                {
                    whereParametersList[0].WhereServer = DBNull.Value.ToString();
                }

                #endregion

                staffDurationEntrySpeedQueryInforDataList = DataProvider.GetSelectStaffDurationEntrySpeedQueryInfor(whereParametersList);
            }
            catch (Exception ex)
            {
                Log4Service.Log log = new Orid.Management.Statistics.Service.Log4Service.Log();
                log.Error("WCFStaffCorrelation SelectStaffDurationEntrySpeedQueryInfor Error:" + ex.Message);
            }

            return staffDurationEntrySpeedQueryInforDataList;
        }
        #endregion 全员别 期间别 生产性

        #region 全员别 稼动率
        /// <summary>
        /// 全员别 稼动率  查询
        /// </summary>
        /// <param name="whereParametersList">where 的参数列表</param>
        /// <returns>返回 StaffWorkEfficQueryData 的LIST 形式</returns>
        public List<StaffWorkEfficQueryData> SelectStaffWorkEfficiencyInfor(List<WhereParameters> whereParametersList)
        {
            try
            {
                List<StaffWorkEfficQueryData> retStaffWorkEfficiencyList = null;

                #region 参数形式转换
                ////日期
                if (!whereParametersList[0].WhereentryDateFrom.Equals("null"))
                {
                    whereParametersList[0].WhereentryDateFrom = whereParametersList[0].WhereentryDateFrom.ToString().Trim();
                }

                if (!whereParametersList[0].WhereentryDateTo.Equals("null"))
                {
                    whereParametersList[0].WhereentryDateTo = whereParametersList[0].WhereentryDateTo.ToString().Trim();
                }
                #endregion 参数设置

                if (!string.IsNullOrEmpty(whereParametersList[0].WhereStatsticClass))
                {
                    switch (whereParametersList[0].WhereStatsticClass.ToString().Trim().ToUpper())
                    {
                        case "DAY":
                            retStaffWorkEfficiencyList = DataProvider.GetSelectStaffWorkEfficiencyDay(whereParametersList);
                            break;

                        case "HOUR":
                            retStaffWorkEfficiencyList = DataProvider.GetSelectStaffWorkEfficiencyHour(whereParametersList);
                            break;
                    }
                }

                return retStaffWorkEfficiencyList;
            }
            catch (Exception ex)
            {
                Log4Service.Log log = new Orid.Management.Statistics.Service.Log4Service.Log();
                log.Error("WCFUnitCorrelation SelectStaffWorkEfficiency Error:" + ex.Message);
            }

            return null;
        }

        #endregion 全员别 稼动率
    }
}
